package com.beiding.service.impl;

import com.beiding.pojo.Message;
import com.beiding.pojo.payload.Payload;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class MessageSender {


    private RabbitTemplate rabbitTemplate;

    public MessageSender(RabbitTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
    }

    //给房东发消息
    public void sendToLandlord(String receiver, Payload payload) {
        rabbitTemplate.convertAndSend("message.send.landlord", Message.create(receiver, payload));
    }


    //给房客发消息
    public void sendToTenant(String receiver, Payload payload) {
        rabbitTemplate.convertAndSend("message.send.tenant", Message.create(receiver, payload));
    }



}
